package com.dsteiner.gwt.cafeteriasophia.client;



import com.dsteiner.gwt.cafeteriasophia.client.controller.StatisticController;
import com.dsteiner.gwt.cafeteriasophia.client.model.ShiftChangeSelectionModel;
import com.dsteiner.gwt.cafeteriasophia.client.model.StatisticModel;
import com.dsteiner.widgets.client.Widgets.FlowPanelExt;
import com.dsteiner.widgets.client.Widgets.HTMLExt;
import com.dsteiner.widgets.client.Widgets.IWidget;
import com.dsteiner.widgets.client.Widgets.IWidgetBuilder;
import com.dsteiner.widgets.client.Widgets.LazyWidget;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;

public class StatisticWidget extends LazyWidget implements IWidgetBuilder{

	private StatisticController statisticController = new StatisticController();
	private final StatisticModel statisticModel;

	public StatisticWidget(StatisticModel statisticModel) {
		this.statisticModel = statisticModel;
		setStyleName("statistic-widget");
	}

	@Override
	public Widget createContentWidget() {
		FlowPanel mainPanel = new FlowPanel();
		FlowPanelExt contentPanel = new FlowPanelExt();
		HTMLExt statisticHtml = new HTMLExt();
		
		mainPanel.add(contentPanel);
		mainPanel.add(statisticHtml);
		
		statisticHtml.getElement().getStyle().setPaddingTop(20, Unit.PX);
		
		statisticController.registerStatisticHtml(statisticHtml);
		statisticController.registerContentPanel(contentPanel);
		statisticController.registerStatisticWidget(this);
		statisticController.registerWidgetWidget(this);
		statisticController.registerStatisticModel(statisticModel);
		return mainPanel;
	}

	public IWidget createWidget(Object model) {
		return new ShiftChangeSelectionWidget((ShiftChangeSelectionModel)model, statisticModel);
	}

}